<template>
  <div id="app">
    <h4>1.state,action,mutation,getter</h4>
    {{ $store.state.count }}
    <br />
    <!-- {{$store.getters.doubleCount}} -->
    {{ doubleCount }}
    <br />
    <button @click="increment2">count++</button>

    <h4>2.mudule</h4>
    {{ $store.state.name }}
    {{ $store.state.a.name }}
    {{ $store.state.b.name }}
    <br />
    <button @click="$store.commit('changeName')">changeName</button>
    <br />
    <button @click="$store.commit('a/changeName')">changeName小A</button>

    <h4>3.商城</h4>
    <div v-for="item in getShops" :key="item.id">
      {{ item.title }}
      <button @click="addItem(item)">添加到购物车</button>
    </div>
    <p>购物车：</p>
    {{ getItems }}
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'App',
  computed: {
    ...mapGetters(['doubleCount']),
    ...mapGetters(['getShops']),
    ...mapGetters(['getItems']),
    count() {
      return this.$store.state.count
    },
  },
  methods: {
    ...mapActions(['increment2']),
    ...mapActions(['addItem']),
  },
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
